part of '../repository.dart';

const _kLightThemeModeValue = 'light';
const _kDarkThemeModeValue = 'dark';
const _kSystemThemeModeValue = 'system';

class _ThemeModeDto extends Equatable {
  const _ThemeModeDto._internal({
    required this.themeModeString,
  });

  final String themeModeString;

  @override
  List<Object?> get props {
    return [
      themeModeString,
    ];
  }

  factory _ThemeModeDto.fromString(String themeModeString) {
    return _ThemeModeDto._internal(
      themeModeString: themeModeString,
    );
  }

  factory _ThemeModeDto.fromEntity(ThemeMode themeMode) {
    final themeModeString = switch (themeMode) {
      ThemeMode.light => _kLightThemeModeValue,
      ThemeMode.dark => _kDarkThemeModeValue,
      ThemeMode.system => _kSystemThemeModeValue,
    };

    return _ThemeModeDto._internal(
      themeModeString: themeModeString,
    );
  }

  @override
  String toString() {
    return themeModeString;
  }

  ThemeMode toEntity() {
    return switch (themeModeString) {
      _kLightThemeModeValue => ThemeMode.light,
      _kDarkThemeModeValue => ThemeMode.dark,
      _kSystemThemeModeValue => ThemeMode.system,
      _ => throw UnimplementedError(),
    };
  }
}
